
package edu.tongji.jiaowu.dao.jdbc;
 
import java.util.List;

import edu.tongji.jiaowu.dao.ExternalScoreDao;
import com.tongji.quickCRUDQ.define.Row;
import com.tongji.quickCRUDQ.model.CommonBean;
import com.tongji.quickCRUDQ.dao.jdbc.BaseDaoJdbc;

public class ExternalScoreDaoJdbc extends BaseDaoJdbc implements ExternalScoreDao {
	String tableName="T_EXTERNAL_SCORE";
	String beanName="externalScore";
	
	public CommonBean createExternalScore(){
		CommonBean externalScores=this.createBean(tableName,beanName);
                return externalScores;		
	}
	
/*
	public CommonBean findExternalScores(String refid) {
		CommonBean externalScores=this.createExternalScore();
		String sql="select * from T_EXTERNAL_SCORE where refid=?";
		List data=this.getCommonDao().select(sql,new String[]{refid});
		externalScores.addData(data);
                return externalScores;
       }
*/
	public CommonBean findExternalScoreById(String id) {
		CommonBean externalScores=this.createExternalScore();
		String sql="select * from T_EXTERNAL_SCORE where id=?";
		List data=this.getCommonDao().select(sql,new String[]{id});
		externalScores.addData(data);
    return externalScores;
  }
  
	public CommonBean findAllExternalScores() {
		CommonBean externalScores=this.createExternalScore();
		String sql="select * from T_EXTERNAL_SCORE ";
		List data=this.getCommonDao().select(sql,new String[]{});
		externalScores.addData(data);
    return externalScores;
  }
	public void insertExternalScore(CommonBean externalScoreBean){
		List data=externalScoreBean.getData();
		Row row=this.getRow(tableName);
		this.getCommonDao().templateBatchInsert(row,data,this.getIdGenerator());
	}
	public void updateExternalScore(CommonBean externalScoreBean){
		List data=externalScoreBean.getData();
		Row row=this.getRow(tableName);
		this.getCommonDao().templateBatchUpdate(row,data);
	}

	public boolean check(String entryType, String studentNo) {
		String sql="select count(*) from T_EXTERNAL_SCORE where is_pass='Y' and external_exam_type=? and  student_no=?";
		String cnt=getCommonDao().getString(sql, new String[]{entryType,studentNo});
		return !"0".equals(cnt);
	}
}

